package Modes;

import java.util.List;

import com.game.ThauanFramework.GameObject;
import com.game.ThauanFramework.Util;
import com.thauanLopes.bacterium.GameSceneView;
import com.thauanLopes.bacterium.GameManages.GameManager;
import com.thauanLopes.bacterium.GameManages.GameManagerFactory;

public class EspecialItemManager {

	private GameManager gameManager;

	private double cronometro;
	private float nextInterval;

	private float minTime = 5;
	private float maxTime = 15;

	private boolean isAlive = true;

	private List<GameObject> gameObjects;
	private List<GameObject> cemetery;
	
	private GameSceneView gsView;

	private float GetNextInterval(float minTime, float maxTime) {
		float tmpNextInterval = minTime
				+ (Util.getRandom().nextFloat() * (maxTime - minTime));
		return tmpNextInterval;
	}

	public EspecialItemManager(GameManager gameManager,
			List<GameObject> gameObjects, List<GameObject> cemetery, GameSceneView gsView) {
		
		this.gsView = gsView;
		this.gameManager = gameManager;
		this.gameObjects = gameObjects;
		this.cemetery = cemetery;
		this.nextInterval = GetNextInterval(this.minTime, this.maxTime);
	}

	public void Update(double deltaTime)
	{
		if(this.isAlive)
		{
			// Verificar para instanciar
			this.cronometro += deltaTime;
			if(this.cronometro >= this.nextInterval)
			{
				this.cronometro = 0;
				this.nextInterval = GetNextInterval(this.minTime, this.maxTime);				
				//ChangeModeItem item = new ChangeModeItem(this.gameObjects, this.cemetery, this.gsView,GameManagerFactory.MODE_QTE_BACTERIA);
				ChangeModeItem item = new ChangeModeItem(this.gameObjects, this.cemetery, this.gsView,GameManagerFactory.getRandmMode());
				this.gameObjects.add(item);
			}
		}
	}
}
